Skip to content

feat(contract): improve eventIterator schema output type - #970

Merged
dinwwwh merged 1 commit into
mainfrom
feat/contract/improve-eventIterator-schema-output-type
Sep 6, 2025
Merged

feat(contract): improve eventIterator schema output type#970
dinwwwh merged 1 commit into
mainfrom
feat/contract/improve-eventIterator-schema-output-type

Conversation

@dinwwwh

@dinwwwh dinwwwh commented Sep 5, 2025

Copy link
Copy Markdown
Member

iteartor.return() now possible without ? for typesafety

@vercel

vercel Bot commented Sep 5, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
orpc Ready Ready Preview Comment Sep 5, 2025 0:07am

@coderabbitai

coderabbitai Bot commented Sep 5, 2025

Copy link
Copy Markdown

Walkthrough

The return type of eventIterator in packages/contract/src/event-iterator.ts was updated to use AsyncIteratorClass for the output schema type. An import for AsyncIteratorClass from @orpc/shared was added. No runtime logic changes were made.

Changes

Cohort / File(s) Summary
Contract type signature update
packages/contract/src/event-iterator.ts
Changed eventIterator return type from Schema<AsyncIteratorObject<...>, AsyncIteratorObject<...>> to Schema<AsyncIteratorObject<...>, AsyncIteratorClass<...>>; added import for AsyncIteratorClass; no runtime logic changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • unnoq/orpc#619 — Aligns event-iterator to return AsyncIteratorClass and adds corresponding import, mirroring this type-level change.

Poem

I twitch my nose at types that pass,
From Object to a Class at last.
No loops were moved, no maps undone,
Just signatures beneath the sun.
Carrot in paw, I stamp and cheer—
The iterator’s path is clear! 🥕🐇


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 12bfc14 and f3bbb07.

📒 Files selected for processing (1)
  • packages/contract/src/event-iterator.ts (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
packages/contract/src/event-iterator.ts (2)
packages/contract/src/schema.ts (1)
  • Schema (5-5)
packages/shared/src/iterator.ts (1)
  • AsyncIteratorClass (25-98)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: lint
  • GitHub Check: publish-commit
  • GitHub Check: test
🔇 Additional comments (2)
packages/contract/src/event-iterator.ts (2)

1-1: LGTM: type-only import is correct

Keeps runtime clean and avoids cycles.


22-22: Preserve backward compatibility for eventIterator’s Schema output
The runtime emits AsyncIteratorClass (mapEventIterator returns AsyncIteratorClass<TMap,TMap,TNext>) but the Schema is now typed as AsyncIteratorClass, which is invariant. To smooth migration for any consumers typed against AsyncIteratorObject, consider this optional tweak:

- ): Schema<AsyncIteratorObject<TYieldIn, TReturnIn, void>, AsyncIteratorClass<TYieldOut, TReturnOut, void>> {
+ ): Schema<
+    AsyncIteratorObject<TYieldIn, TReturnIn, void>,
+    AsyncIteratorObject<TYieldOut, TReturnOut, void> & AsyncIteratorClass<TYieldOut, TReturnOut, void>
+> {

Manually verify external consumer typings for Schema<…, AsyncIteratorObject<…>>.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/contract/improve-eventIterator-schema-output-type

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Sep 5, 2025

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @unnoq, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refines the type definitions within the contract module, specifically for asynchronous iterators. By updating the schema's output type, the change aims to improve type accuracy and consistency, ensuring that the contract definitions more precisely reflect the expected structure of async iterator outputs.

Highlights

  • Type Definition Refinement: The output type for the eventIterator schema has been updated from AsyncIteratorObject to AsyncIteratorClass. This change enhances the precision of type definitions for asynchronous iterators within the contract.
  • New Type Import: A new type, AsyncIteratorClass, has been imported from the @orpc/shared package to support the updated schema definition.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@codecov

codecov Bot commented Sep 5, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request aims to improve the output type of the eventIterator schema by making it more specific. While changing from AsyncIteratorObject to AsyncIteratorClass is a good step, the generic type arguments for AsyncIteratorClass are incorrect, leading to a type mismatch with the actual returned value. I've left a comment explaining the issue in detail.

Comment thread packages/contract/src/event-iterator.ts
@pkg-pr-new

pkg-pr-new Bot commented Sep 5, 2025

Copy link
Copy Markdown
More templates

@orpc/arktype

npm i https://pkg.pr.new/@orpc/arktype@970

@orpc/client

npm i https://pkg.pr.new/@orpc/client@970

@orpc/contract

npm i https://pkg.pr.new/@orpc/contract@970

@orpc/experimental-durable-event-iterator

npm i https://pkg.pr.new/@orpc/experimental-durable-event-iterator@970

@orpc/hey-api

npm i https://pkg.pr.new/@orpc/hey-api@970

@orpc/interop

npm i https://pkg.pr.new/@orpc/interop@970

@orpc/json-schema

npm i https://pkg.pr.new/@orpc/json-schema@970

@orpc/nest

npm i https://pkg.pr.new/@orpc/nest@970

@orpc/openapi

npm i https://pkg.pr.new/@orpc/openapi@970

@orpc/openapi-client

npm i https://pkg.pr.new/@orpc/openapi-client@970

@orpc/otel

npm i https://pkg.pr.new/@orpc/otel@970

@orpc/react

npm i https://pkg.pr.new/@orpc/react@970

@orpc/react-query

npm i https://pkg.pr.new/@orpc/react-query@970

@orpc/experimental-react-swr

npm i https://pkg.pr.new/@orpc/experimental-react-swr@970

@orpc/server

npm i https://pkg.pr.new/@orpc/server@970

@orpc/shared

npm i https://pkg.pr.new/@orpc/shared@970

@orpc/solid-query

npm i https://pkg.pr.new/@orpc/solid-query@970

@orpc/standard-server

npm i https://pkg.pr.new/@orpc/standard-server@970

@orpc/standard-server-aws-lambda

npm i https://pkg.pr.new/@orpc/standard-server-aws-lambda@970

@orpc/standard-server-fetch

npm i https://pkg.pr.new/@orpc/standard-server-fetch@970

@orpc/standard-server-node

npm i https://pkg.pr.new/@orpc/standard-server-node@970

@orpc/standard-server-peer

npm i https://pkg.pr.new/@orpc/standard-server-peer@970

@orpc/svelte-query

npm i https://pkg.pr.new/@orpc/svelte-query@970

@orpc/tanstack-query

npm i https://pkg.pr.new/@orpc/tanstack-query@970

@orpc/trpc

npm i https://pkg.pr.new/@orpc/trpc@970

@orpc/valibot

npm i https://pkg.pr.new/@orpc/valibot@970

@orpc/vue-colada

npm i https://pkg.pr.new/@orpc/vue-colada@970

@orpc/vue-query

npm i https://pkg.pr.new/@orpc/vue-query@970

@orpc/zod

npm i https://pkg.pr.new/@orpc/zod@970

commit: f3bbb07

@dinwwwh
dinwwwh merged commit c79fd64 into main Sep 6, 2025
11 checks passed
@dinwwwh
dinwwwh deleted the feat/contract/improve-eventIterator-schema-output-type branch June 22, 2026 01:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant